﻿#include "treeNode.h"

TreeNode::TreeNode()
{

}

TreeNode::TreeNode(int idx){
    this->idx = idx;
}

/** @brief 打印所有路径，调试用
 *  @param 返回要打印的字符串   */
QString TreeNode::print(){
    QString res = "->"+QString::number(idx)+"["+QString::number(forkNum)+"]";
    if(idx != -1){
        foreach(TreeNode* node, son){
            res.append("|");
            res.append(node->print());
        }
    }
    return res;
}

void TreeNode::updateForkNum(int forkNum){
    this->forkNum = forkNum;
    if(idx != -1){
        foreach(TreeNode* node, son){
            node->updateForkNum(forkNum * son.size());
        }
    }
}
